<h4 class="head-title">服务端信息</h4>
<div class="tableform">
    <div class="division">
        <form method="post" action="index.php?app=o2o&ctl=admin_server&act=save" id="server">
            <input type="hidden" name="server[server_id]" value="<{$server.server_id}>" />
            <table width="100%" cellspacing="0" cellpadding="0" border="0" >
            <tbody>
            <tr>
              <th><em class="c-red">*</em> 服务端编码：</th>
              <td><{if $server.server_bn}><{$server.server_bn}><{else}><{input type='text&&required' name="server[server_bn]" value=$server.server_bn}><{/if}>
              <input type='hidden' name="server[old_server_bn]" value="<{$server.server_bn}>">
              <{help}><{t}>服务端在系统中的唯一标识<{/t}><{/help}>
              </td>
            </tr>
            <tr>
            <th ><em class="c-red">*</em> 名称：</th>
              <td><{input type="text&&required" size="32" name="server[name]" value=$server.name}>
              <{help}><{t}>服务端在此系统需要显示的中文名称<{/t}><{/help}>
              </td>
            </tr>
            <tr>
            <th ><em class="c-red">*</em> 服务端类型：</th>
              <td><{input type='select' name='server[type]' id='server_type' vtype='required' rows=$type_list valueColumn=type labelColumn=desc value=$server.type}>
              <{help}><{t}>服务端对接联通的模式<{/t}><{/help}>
              </td>
            </tr>
            <tr class="webpos_conf">
              <th><em class="c-red">*</em> 远程服务器地址：</th>
              <td><input type="text" name="server[remote_url]" size="60" value="<{$server.remote_url|default:'http://'}>"/>
              <{help}><{t}>对接的请求服务器地址<{/t}><{/help}>
              </td>
            </tr>
            <tr class="webpos_conf">
              <th><em class="c-red">*</em> 私钥：</th>
              <td><input type="text" name="server[sign_key]" size="32" maxlength="6" value="<{$server.sign_key}>"/>
              <{help}><{t}>对接的验签私钥<{/t}><{/help}>
              </td>
            </tr>
            </tbody>
            </table>

            <div class="table-action">
            <{button class="btn-primary" type="button" id="saveserver" name="submit" label="提交"}>
            </div>
        </form>
    </div>
</div>

<script>
$('server_type').addEvents({
    'change':function(e){
        if (!this.value) return;

        if(this.value == 'webpos'){
            $ES('.webpos_conf').show();
        }else{
            $ES('.webpos_conf').hide();
        }
    },

    'domready':function(e){
        $ES('.webpos_conf').hide();
        this.fireEvent('change',e);
    }
});

$('saveserver').addEvent('click',function(event){
    $('server').fireEvent('submit',new Event(event));
});

$('server').store('target',{
    onRequest:function(){
       $('saveserver').set('disabled', 'true');
    },
    onComplete:function(jsontext){
       var json = Json.evaluate(jsontext);
       if (typeof(json.error) != 'undefined'){
           $('saveserver').set('disabled', '');
       }else{
           $('saveserver').set('disabled', 'true');
           opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(400,opener.finderGroup['<{$env.get.finder_id}>']);
           window.close();
       }
    }
});

</script>